package my.study.org.springframework.jdbc.examples.example1;

import my.base.util.FileUtil;
import my.study.org.springframework.jdbc.examples.example1.bo.User;
import my.study.org.springframework.jdbc.examples.example1.mapper.UserMapper;

import org.apache.commons.lang.builder.ToStringBuilder;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class AppMain {

	private static ApplicationContext context = new ClassPathXmlApplicationContext(
			FileUtil.getPath(AppMain.class) + "/jdbc-applicationContext.xml");

	/**
	 * 使用Mybatis的mapper查询数据库
	 * @param args
	 */
	public static void main(String[] args) {
		UserMapper userMapper = (UserMapper) context.getBean("userMapper");
		User user = userMapper.selectOne(1);
		System.out.println(ToStringBuilder.reflectionToString(user));
	}
}
